package ClassAnalyzerTest;


import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import devaluator.functionality.Classparser;
import devaluator.functionality.ClassAnalyzer;

public class ClassAnalyzerTests {
	
	ClassAnalyzer analyzerTest = null;
	ArrayList<ArrayList<String>> y = new ArrayList<ArrayList<String>>();
	
	ArrayList<String> PList = new ArrayList<String>();
	ArrayList<String> TList = new ArrayList<String>();
 	int act,exp;
	

	
	@Before
	public void setUp() throws Exception {
		analyzerTest = new ClassAnalyzer();
		PList.add("public class TestedInterface ");
		PList.add("public class TestedFile ");
		PList.add("public class TestedPackage ");
		PList.add("public interface TestedInterface ");
		PList.add("import package java.util.Random;");
		y = analyzerTest.process(PList);
	}

	
	@Test
	//The process method should know the number of classes in the input from parser"
	public void testProcessMethodForClasses() {
		act = 0;
		exp = 1;
		TList = y.get(0);
		System.out.println(TList.get(TList.size()-1));
		if (TList.get(TList.size()-1).equals("\nTotal Classes: 3"))
				act = act +1;
		assertEquals("match method fails in finding classes",exp,act);
	}
	
	@Test
	//The process method should know the number of interfaces in the input from parser"
	public void testProcessMethodForInterfacess() {
		act = 0;
		exp = 1;
		TList = y.get(1);
		System.out.println(TList.get(TList.size()-1));
		if (TList.get(TList.size()-1).equals("\nTotal Interfaces: 1"))
				act = act +1;
		assertEquals("match method fails in finding classes",exp,act);
	}
	
	@Test
	//The process method know catch the number of packages in the input from parser"
	public void testProcessMethodForPackages() {
		act = 0;
		exp = 1;
		TList = y.get(2);
		System.out.println(TList.get(TList.size()-1));
		if (TList.get(TList.size()-1).equals("\nTotal Packages: 1"))
				act = act +1;
		assertEquals("match method fails in finding classes",exp,act);
	}
	
	
	
	
	@After
	public void tearDown() throws Exception {
		y = null;
		analyzerTest = null;
		PList = null;
		TList = null;
	}

}
